In a database, any number of “objects,” “records,” or “rows” can be represented. A schema specifies a number of “fields,” “attributes,” or “members” for which a value can be stored for each object, record, or row. For example, the schema for an Employees table may specify the following fields: Name, Position, Salary, and Overhead. A sample portion of this table is shown below in Table 1.
TABLE 1NamePositionSalaryBenefitsAnn BattleAccountant$77,000$17,500Greg HammAssistant$51,000$16,000
In some cases, the designer of a database table may wish to include a calculated field in the schema for the table. For example, a designer may wish to modify the schema for the table shown in Table 1 below to include the calculated field Total Cost, defined to be the sum of Salary and Benefits. Table 2 below shows the inclusion of the Total Cost calculated field.
TABLE 2NamePositionSalaryBenefitsTotal CostAnn BattleAccountant$77,000$17,500$94,500Greg HammAssistant$51,000$16,000$67,000
In populating the table shown in Table 2, for each row, the values of the Name, Position, Salary, and Benefits fields are obtained for each row from an external data source, or entered by a person. In some cases, such non-calculated fields are called “base fields” herein. Based on the definition of the Total Cost calculated field associated with the schema, the database itself calculates the value of the calculated field for each row, such as by adding $77,000 to $17,500 to obtain $94,500 for the Total Cost field in the first row.